
#ifndef PARSER_H
#define PARSER_H

#include "lexer.h"

int t, tokens[30], tokens_pt, seq_tokens[30], seq_start, seq_len;
char *seq_msg[30], *error_msg;

#define PUSH(X) tokens[tokens_pt++] = X
#define POP() tokens[--tokens_pt]

#define INIT_SEQ() seq_start = seq_len = 0
#define TOP_SEQ_T() seq_tokens[seq_start]
#define TOP_SEQ_MSG() seq_msg[seq_start]
#define ADD_SEQ(X,M) seq_tokens[seq_len] = X;\
										 seq_msg[seq_len++] = M
#define NEXT_SEQ() seq_start++
#define EMPTY_SEQ() (seq_start==seq_len)
#define FREE_SEQ() free(seq_msg[seq_start])
											 
#define MATCH_TOKEN(X,M) readToken();\
	if(t != X){ error_msg=M; printf("Erro: %s e apareceu %d\n",error_msg,t); return 0; }\
	else{ printf("%d ok\n",t); }
	
#define OK() printf("%d ok\n",t)


void init_parser();
int start();
void readToken();
void remToken();

int is_type();

int Goal();
int MainClass();
int VarDeclaration();
int VarDeclarationStatement();
int MethodDeclaration();
int FormalListParameter();
int MethodBody();
int Statement();
int Expression();

#include "parser.c"

#endif